fix(decopilot): prevent Cloudflare 524 timeout on stream endpoint#2509
Merged
JonasJesus42 merged 1 commit intomainfrom Feb 27, 2026
Merged
fix(decopilot): prevent Cloudflare 524 timeout on stream endpoint#2509JonasJesus42 merged 1 commit intomainfrom
JonasJesus42 merged 1 commit intomainfrom
Conversation
Move MCP client creation (clientFromConnection, createVirtualClientFrom, createModelProviderFromClient) from the synchronous request handler into the stream execute callback. This ensures the SSE response headers are flushed to the client immediately, before the potentially slow MCP connection setup begins. Previously, the handler awaited all MCP client connections before returning createUIMessageStreamResponse, causing Cloudflare to timeout (524) when client initialization exceeded 100 seconds. Agent-specific system instructions are now lazily enriched inside execute once the passthrough client is available, identified by the stable message id decopilot-system. Made-with: Cursor
Contributor
🧪 BenchmarkShould we run the Virtual MCP strategy benchmark for this PR? React with 👍 to run the benchmark.
Benchmark will run on the next push after you react. |
Contributor
Release OptionsShould a new version be published when this PR is merged? React with an emoji to vote on the release type:
Current version: Deployment
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Move MCP client creation (clientFromConnection, createVirtualClientFrom, createModelProviderFromClient) from the synchronous request handler into the stream execute callback. This ensures the SSE response headers are flushed to the client immediately, before the potentially slow MCP connection setup begins.
Previously, the handler awaited all MCP client connections before returning createUIMessageStreamResponse, causing Cloudflare to timeout (524) when client initialization exceeded 100 seconds.
Agent-specific system instructions are now lazily enriched inside execute once the passthrough client is available, identified by the stable message id decopilot-system.
Made-with: Cursor
What is this contribution about?
Screenshots/Demonstration
How to Test
Migration Notes
Review Checklist
Summary by cubic
Prevents Cloudflare 524 timeouts on the Decopilot stream endpoint by moving MCP client setup into the SSE execute callback so headers flush immediately. Agent instructions are now injected lazily once the passthrough client is ready.
Written for commit c84fcf2. Summary will update on new commits.